package com.qm.chp03operator;

/**
 * @author wb
 * @date 2023-06-10 10:41
 * @description: 算数运算符
 */
public class Myoperator1 {
    public static void main(String[] args) {
        // 整数运算只能是整数
        int a = 10;
        int b = 5;
        System.out.println(a + b);// 15
        System.out.println(a - b);// 5
        System.out.println(a * b);// 50
        System.out.println(a / b);// 2
        System.out.println(a % b);// 0
        b = 3;
        System.out.println(a + b);// 13
        System.out.println(a - b);// 7
        System.out.println(a * b);// 30
        System.out.println(a / b);// 3
        System.out.println(a % b);// 1

        // 小数运算才能得到小数
        float c = 3.0f;
        double d = 3.0;
        System.out.println(a / c); // 3.3333333
        System.out.println(a / d); // 3.3333333333333335
        System.out.println(a % c); // 1.0
        System.out.println(a % d); // 1.0
        System.out.println(0.1 + 0.2); // 0.30000000000000004

        System.out.println(10.0 / 0.0); // Infinity
        System.out.println(0.0 / 0.0); // NaN
        // 当整数除以 0 的时候（10 / 0），会抛出异常：

        int x = 10;
        int y = ++x;
        System.out.println(y + " " + x);// 11 11
        x = 10;
        y = x++;
        System.out.println(y + " " + x);// 10 11
    }
}
